package com.eliza.nava.fg.b

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.Navigation
import com.eliza.nava.R

class BFg1 : Fragment() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    /**
     * 官方推荐数据传递方式：safeArgs
     *  dependencies {
    classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.2"
    }

    Module的build.gradle 中依赖插件
    apply plugin: "androidx.navigation.safeargs"


    navigation.xml 添声明需要传递的数据
     * */
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        val view = inflater.inflate(R.layout.fragment_b_fg1, container, false)
        /**
         * safeArgs会根据nav_graph中的fragment标签生成对应的类，
         * action标签会以“类名+Directions”命名，argument标签会以“类名+Args”命名。
         * */
        view.findViewById<View>(R.id.fg_b_1to2_btn).setOnClickListener {
            Navigation.findNavController(view).apply {
//                navigate(R.id.action_BFg1_to_BFg2)

                Log.d(this::class.java.name,"")
//                navigate(BFg1Directions.actionBFg1ToBFg2().n)
            }
        }
        return view
    }


}